package com.enjoyor.health.HGPT.core.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.enjoyor.health.HGPT.core.dto.TestQuestionDto;
import com.enjoyor.health.HGPT.core.entity.SelftestQuestion;
import com.enjoyor.health.HGPT.core.mapper.SelftestQuestionMapper;
import com.enjoyor.health.HGPT.core.service.ISelftestQuestionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Maps;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author enjoyor
 * @since 2023-10-18
 */
@Service
public class SelftestQuestionServiceImpl extends ServiceImpl<SelftestQuestionMapper, SelftestQuestion> implements ISelftestQuestionService {

    @Override
    public List<TestQuestionDto> getTestQuestionDtoListById(String selftestId) {
        Map<String, Object> map = Maps.newHashMap();
        map.put("selftest_id", selftestId);
        return baseMapper.getTestQuestionDtoListById(map);
    }

    @Override
    public List<SelftestQuestion> getSelftestQuestionById(String selftestId) {
        LambdaQueryWrapper<SelftestQuestion> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(SelftestQuestion::getSelftestId, selftestId)
                .orderByAsc(SelftestQuestion::getSn)
                .orderByAsc(SelftestQuestion::getOptions);
        return baseMapper.selectList(wrapper);
    }
}
